package com.calefk.util {
    import com.calefk.core.Library;
	/**
     * ...
     * @author 
     */
    public class SoundMaster {
        
        public var sounds:Array;
        private var mLibrary:Library;
        
        public function SoundMaster(library:Library = null) {
            mLibrary = library;
            sounds = new Array();
        }
        
        public function registerSound(id_sound:String):void {
            sounds[id_sound] = new SoundFx(id_sound , mLibrary);
        }
        
        public function playSound(id_sound:String , volumen:Number = 1 , eventComplete:Function = null):void {
            var sound:SoundFx = sounds[id_sound];
            sound.play(volumen , eventComplete);
        }
        
        public function playSoundMulti(id_sound:String , loop:int = 2 , volumen:Number = 1 , eventComplete:Function = null):void {
            var sound:SoundFx = sounds[id_sound];
            sound.playMulti(loop , volumen , eventComplete);            
        }
        
        public function pauseSounds():void {
            for (var name:String in sounds) {
                var sound:SoundFx = sounds[name];
                sound.pause();
            }
        }
        
        public function unpauseSounds():void {
            for (var name:String in sounds) {
                var sound:SoundFx = sounds[name];
                sound.unpause();
            }           
        }
        
        public function playFast(id_sound:String):void {
             var sound:SoundFx = sounds[id_sound];
            sound.play();           
        }
        
        public function stopSound(id_sound:String):void {
             var sound:SoundFx = sounds[id_sound];
            sound.stop();          
        }
        
        public function stopAllSounds():void {
            for each (var sound:SoundFx in sounds ) {
                sound.stop();
            }
        }
    }
}